<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>9.数据出栈与入栈及填充操作</title>
</head>

<body>
  <script>
    let array = ['hdcms', 'houdunren'];
    // 尾部弹出，改变数组
    //let vars = array.pop();//houdunren
    // 头部弹出，改变数组
    // let vars = array.shift();//hdcms
    //头部加入,可以加多个元素,返回值是数组长度
    let vars = array.unshift("aaa","bbb");
    
    console.log(vars);
    console.table(array);
    //填充一样的元素
    console.log(Array(6).fill('houdunren'));//(6) ['houdunren', 'houdunren', 'houdunren', 'houdunren', 'houdunren', 'houdunren']
    //指定填充位置,第一个参数开始位置，第二个参数结束位置(实际上会-1)
    console.log([1,2,3,4].fill('houdunren',1,3));//(4) [1, 'houdunren', 'houdunren', 4]
    
  </script>
</body>

</html>